{% extends "base.html" %}

{% block title %}{{ creator.username }}的主页{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row">
        <div class="col-md-3">
            <div class="card">
                <div class="card-body text-center">
                    <h4>{{ creator.username }}</h4>
                    <p class="text-muted">{{ creator.email }}</p>
                    {% if profile %}
                    {% if profile and profile.specialty %}
                        <p class="text-primary">{{ profile.specialty }}</p>
                    {% else %}
                        <p class="text-muted">未设置专长领域</p>
                    {% endif %}
                        {% if profile.bio %}
                            <p>{{ profile.bio }}</p>
                        {% endif %}
                    {% endif %}
                    <div class="mt-3">
                        <span class="text-muted">粉丝: {{ followers_count }}</span>
                    </div>
                    {% if current_user.id == creator.id %}
                        <a href="{{ url_for('edit_specialty') }}" class="btn btn-sm btn-outline-primary mt-2">
                            编辑专长
                        </a>
                    {% else %}
                        <form method="POST" action="{{ url_for('follow_user' if not is_following else 'unfollow_user', user_id=creator.id) }}" class="mt-2">
                            <button type="submit" class="btn btn-sm {{ 'btn-outline-danger' if is_following else 'btn-primary' }}">
                                {{ '取消关注' if is_following else '关注' }}
                            </button>
                        </form>
                    {% endif %}
                </div>
            </div>
        </div>
        <div class="col-md-9">
            <h4>我的内容</h4>
            {% if contents %}
                <div class="list-group">
                    {% for item in contents %}
                        <a href="#" class="list-group-item list-group-item-action">
                            <div class="d-flex w-100 justify-content-between">
                                <h5 class="mb-1">{{ item.title }}</h5>
                                <small>{{ item.created_at.strftime('%Y-%m-%d') }}</small>
                            </div>
                            {% if item.__class__.__name__ == 'Content' %}
                                <p class="mb-1">{{ item.description }}</p>
                                <small>类型: {{ item.content_type }} | 状态: {{ item.status }}</small>
                            {% else %}
                                <p class="mb-1">{{ item.content|truncate(100) }}</p>
                                <small>来自讨论板</small>
                            {% endif %}
                        </a>
                    {% endfor %}
                </div>
            {% else %}
                <div class="alert alert-info">暂无内容</div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
